<?php
ob_start();
session_start();

	if(!isset($_SESSION["admin_key"])) {
		header("location:index.php");
	}

include("../conf/config.php");
include("../conf/database.php");
include("../conf/tools.php");

if(!checkRole(SUPER_ADMIN))  header("location:registrants.php");

//note: if word file for dump desired, link to this page like:
//<a href='dump.php?w=1'>link</a>
//if this parameter is not included, file returned will be in excel format
$w=3;
if ($w==1){
$file_type = "msword";
$file_ending = "doc";
}
else {
$file_type = "vnd.ms-excel";
$file_ending = "xls";
}
header("Content-Type: application/$file_type");
header("Content-Disposition: attachment; filename=IT_Mem_Register.$file_ending");
header("Pragma: no-cache");
header("Expires: 0");
//get contents
//define date for title
$now_date = date('d-m-Y H:i');
$title = "Member Registrations as of $now_date";
//$sql = "select * from bkitc_profiles ".$_SESSION['member_where'];
$sql =$_SESSION['member_query'];
$mlist=$_REQUEST["mlist"];
if($mlist!="") $sql =str_replace("where"," where registrant_id in ($mlist) and ",$sql);
if($sql=="") $sql = "select * from bkitc_profiles where rec_status=1";

$memberInfoColNames=Array(
"registrant_id"=>"Registrant ID",
"full_name"=>"Full Name",
"gender"=>"Gender",
"dob"=>"Date Of Birth",
"contact_address"=>"Contact Address",
"reg_city"=>"City",
"reg_state"=>"State",
"reg_country"=>"Country",
"telephone_no"=>"Telephone No",
"mobile_no"=>"Mobile No",
"email_id"=>"Email Id",
"alternate_email_id"=>"Alternate Email Id",
"reg_chat_id"=>"Skype Contact Id",
"technical_specifications"=>"Functional Area",
"reg_technical_remark"=>"Functional Area Expertise",
"edu_qual"=>"Educational Qualifications",
"photo_filename"=>"Photo Filename",
"years_it_exp"=>"Years IT Exprience",
"company_address"=>"Company Address",
"are_you_prof"=>"Is Professional",
"professional_bodies"=>"Professional Bodies",
"are_you_bk"=>"Is BK ?",
"aloukik_dob"=>"Aloukik DOB",
"bk_center_address"=>"BK Center Address",
"bk_center_phone"=>"BK Center Phone",
"bk_center_email"=>"BK Center Email",
"other_info"=>"Other Info",
"submission_date"=>"Submission Date",
"rec_status"=>"rec_status",
"reg_type"=>"Registered Via",
"last_updated"=>"Last Updated",
"reg_bk_stats"=>"Attending Classes",
"reg_notes"=>"Member Notes",
"reg_sig"=>"Member SIG"



);

$result = mysql_query($sql);

$i = mysql_num_fields($result);
echo "Member Registrations as of $now_date ";
$str = '<table border="1" style="border-collapse: collapse"><tr>';

foreach($memberInfoColNames as $colId=>$colName)
{
   $str .= '<th>'.$colName.'</th>';

}
	
 
$str .= '</tr>';

$count = mysql_num_rows($result);
$total = $count;

while ($row = mysql_fetch_array($result)) {
	$str .= '<tr>';
	if($row["are_you_bk"]=="0") $row["aloukik_dob"]="";
	if($row["gender"]=="1") $row["gender"]= "Male"; else $row["gender"]=  "Female";
	if($row["are_you_bk"]=="1") $row["are_you_bk"]=  "Yes"; else $row["are_you_bk"]=  "No";
	if($row["reg_type"]=="1") $row["reg_type"]=  "Site"; else $row["reg_type"]=  "Admin";
	$row["reg_sig"]=getMemberSIGNameList($row["registrant_id"]);
	$row["registrant_id"]= "BKITC".number_pad($row["registrant_id"],5);
	

	foreach($memberInfoColNames as $colId=>$colName)
	{
	  
	   if($colId=="are_you_prof") $row[$colId]=$row[$colId]==1?"Yes":"No";
	   if($colId=="reg_bk_stats") $row[$colId]=$class_status[$row[$colId]];
	   if($colId=="rec_status") $row[$colId]=$row[$colId]==1?"Active":"Deleted";
	   $str .= '<td>'.$row[$colId].'</td>';

	
	}
		

	$str .= '</tr>';
}

$str .= '</table>';

mysql_free_result($result);

echo $str;

?>

